package com.ktgj.customer.common;

import com.alibaba.fastjson.JSONArray;
import com.ktgj.common.core.annotation.Excel;
import com.ktgj.common.core.constant.InsuranceTypeEnum;
import com.ktgj.common.core.utils.HttpClientUtil;
import com.ktgj.customer.domain.Insurance.*;
import com.ktgj.customer.domain.Insurance.dftModel.BuyInsuranceInfo;
import com.ktgj.customer.domain.Insurance.dftModel.BuyInsuranceInput;
import com.ktgj.customer.domain.Insurance.dftModel.BuyInsuranceOutput;
import com.ktgj.customer.domain.Insurance.dftModel.EnumHelp;
import com.ktgj.customer.domain.Insurance.heydayModel.HeydayUrlInfo;
import com.ktgj.customer.domain.Insurance.hlModel.*;
import com.ktgj.customer.util.SysUtils;

import java.net.URLEncoder;
import java.text.SimpleDateFormat;
import java.util.*;

public class test {
    public static void main(String[] args) throws Exception {
//        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm");
//        /**
//         * 航联
//         * */
//        SimpleDateFormat timeDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//        SimpleDateFormat timedate = new SimpleDateFormat("yyyy-MM-dd");
//        SimpleDateFormat format = new SimpleDateFormat("HH:mm:ss");
//        Date date = new Date();
//
//        HanglianUtils hanglianUtils = new HanglianUtils();
//        BankReconciliation reconciliation = new BankReconciliation();
//        reconciliation.setPaymentCode("YEEPAY_FENZHAN");//支付代码
//        reconciliation.setPaymentSerialNumber("q1");//支付流水号
//        reconciliation.setPaymentAmount("5");//支付金额
//        try {
//            reconciliation.setPaymentTime("2022-06-24 00:00:00");//支付时间
//        } catch (Exception e){
//            System.out.println("日期");
//        }
//
//        PolicyHolder policyHolder = new PolicyHolder();
//        policyHolder.setHolderName("北京金色世纪商旅网络科技股份有限公司");//投保人姓名
//        policyHolder.setHolderIdType("BL");//投保人证件类型
//        policyHolder.setHolderId("91110105582501947J");//投保人证件号码
//        policyHolder.setHolderPhone("010-84926666");//投保人联系电话
//
//        PolicyInsured policyInsured = new PolicyInsured();
//        policyInsured.setInsuredName("初艳东");//被保人姓名
//        policyInsured.setInsuredIdType("NI");//被保人证件类型
//        policyInsured.setInsuredId("130828200303065713");//被保人证件号码
//        policyInsured.setInsuredPhone("17338135336");//被保人联系电话
//
//        PolicyBeneficiary policyBeneficiary = new PolicyBeneficiary();
//        policyBeneficiary.setBeneficiaryType("4");//受益人类型
//
//        List<InsuranceLists> insuranceListsList = new ArrayList<>();
//        InsuranceLists insuranceLists = new InsuranceLists();
//
//        Product product = new Product();
//        product.setProductCode("18000000001");//产品代码12135160016
//        product.setInsuranceStartDate("20220714000000");//保险开始日期
//        product.setInsuranceEndDate("20230713235959");//保险截止日期
//
//        Insurance insurance = new Insurance();
//        insurance.setSerialNumber(SysUtils.getUuid().replaceAll("-", ""));//保险序列号
//        insurance.setOperateSerialNumber(SysUtils.getUuid().replaceAll("-", ""));//保险操作序列号
//        insurance.setProduct(product);
//
//        AuisAbe auisAbe = new AuisAbe();
//        auisAbe.setAgentNo("pek602c");//代理人编号aui110c
//        auisAbe.setTicketPrice("1000.0");//机票价格
//        auisAbe.setReissueFlag("0");//改签标记
//        auisAbe.setAirlineNo("867");//航空公司编号
//        auisAbe.setEticketNo("8672340037981");//电子客票号
//        auisAbe.setBaggageNo("5");//行李险单号
//        auisAbe.setTicketType("ARL-D");//机票类型
//        auisAbe.setCarrier("LT");//承运人
//        auisAbe.setFlightNo("LT4329");//航班号
//        auisAbe.setDepartureAirportCode("HRB");//起飞机场三字码
//        auisAbe.setArriveAirportCode("ZUH");//到达机场三字码
//        try {
//            auisAbe.setFlightDate("20220714");//航班日期
//        } catch (Exception e){
//            System.out.println("日期2");
//        }
//
//        auisAbe.setFlightTime("000000");//航班时间
//
//        InsuranceItem insuranceItem = new InsuranceItem();
//        insuranceItem.setAuisAbe(auisAbe);
//
//        insuranceLists.setInsurance(insurance);
//        insuranceLists.setInsuranceItem(insuranceItem);
//
//        insuranceListsList.add(insuranceLists);
//
//        InsuranceInfo insuranceInfo = new InsuranceInfo();
//        insuranceInfo.setPolicyHolder(policyHolder);
//        insuranceInfo.setPolicyInsured(policyInsured);
//        insuranceInfo.setPolicyBeneficiary(policyBeneficiary);
//        insuranceInfo.setInsuranceLists(insuranceListsList);
//
//        InvoiceDelivery invoiceDelivery = new InvoiceDelivery();
//        invoiceDelivery.setIsDelivery("0");//是否配送
////        invoiceDelivery.setRecipientName("熊强强");//收件人
////        invoiceDelivery.setRecipientPhone("18745654672");//收件人电话
////        invoiceDelivery.setDeliveryAddress("0");//配送地址
////        invoiceDelivery.setDeliveryZipCode("北京市东城区东直门南大街5号");//邮政编号
//
//        HLInsurance hlInsurance = new HLInsurance();
//        hlInsurance.setDataSourceCode("AUIS_ABE");//数据来源
//        hlInsurance.setTransferType("TKTS");//传输类型
//        hlInsurance.setFomerOrderId("2021072000010716");//业务方系统订单号
//        hlInsurance.setOperator("hrb888b");//操作人
//        try {
//            hlInsurance.setOperationDate(timedate.format(date));//操作日期
//        } catch (Exception e){
//            System.out.println("日期3");
//        }
//
//        hlInsurance.setOperationTime(format.format(date));//操作时间
//        hlInsurance.setBankReconciliation(reconciliation);
//        hlInsurance.setInsuranceInfo(insuranceInfo);
//        hlInsurance.setInvoiceDelivery(invoiceDelivery);
//
//        Auis auis = hanglianUtils.openInsurance(hlInsurance);
//        System.out.println("\n"+auis+"\n");





        /**
         * 德付通
         * */
        DovePayUtils dovePayUtils = new DovePayUtils();

        List<BuyInsuranceInfo> buyInsuranceInfoList = new ArrayList<>();
        BuyInsuranceInfo buyInsuranceInfo = new BuyInsuranceInfo();
        buyInsuranceInfo.setProtectName("关永乐");//被保人姓名
        buyInsuranceInfo.setProtectCard("110108195411040715");//被保人证件号码
        buyInsuranceInfo.setProtectIdType("I");//被保人证件类型，格式：身份证/护照----I/P（暂时只支持两种格式）
        buyInsuranceInfo.setProtectBirthday("1954-11-04");//被保人生日，格式：yyyyMMdd做保险
        buyInsuranceInfo.setProtectPhone("13801020596");//被保人手机号
        buyInsuranceInfo.setTicketNo("999-3992295696");//被保人票号13位去掉-
        buyInsuranceInfo.setFlightIndex("1");//被保人票号对应的航班序号
        buyInsuranceInfo.setFlightNo("CA1831");//航班号
        buyInsuranceInfo.setDepCity("PEK");//出发城市三字码
        buyInsuranceInfo.setArrCity("SHA");//到达三字码
        buyInsuranceInfo.setDepDateTime("2022-08-04 14:38");//航班起飞时间
        buyInsuranceInfoList.add(buyInsuranceInfo);

        BuyInsuranceInput buyInsuranceInput = new BuyInsuranceInput();
        buyInsuranceInput.setInsuranceType(EnumHelp.InsuranceType.ZA40.getValue());//保险产品类型
        buyInsuranceInput.setBuyInsuranceInfos(buyInsuranceInfoList);//被保人详细信息
        BuyInsuranceOutput buyInsuranceOutput = dovePayUtils.buyInsurance(buyInsuranceInput);
        System.out.println(buyInsuranceOutput.getInsuranceNo());

        /**
         * 航联退保
         * */
        /*HanglianUtils hanglianUtils = new HanglianUtils();
        HLInsurance hlInsurance = new HLInsurance();
        hlInsurance.setDataSourceCode("AUIS_ABE");//数据来源
        hlInsurance.setTransferType("RFND");//传输类型
        hlInsurance.setFomerOrderId("2021072000010716");//业务方系统订单号
        hlInsurance.setOperator("hrb888b");//操作人
        hlInsurance.setOperationDate("2022-07-25");//操作日期
        hlInsurance.setOperationTime("09:56:30");//操作时间

        InsuranceInfo insuranceInfo = new InsuranceInfo();
        List<InsuranceLists> insuranceLists = new ArrayList<>();
        InsuranceLists insuranceList = new InsuranceLists();
        Insurance insurance = new Insurance();
        insurance.setSerialNumber("2818dd34968c4dfd8f5b9e60bc3564ec");//保险序列号
        insurance.setOperateSerialNumber(SysUtils.getUuid().replaceAll("-", ""));//保险操作序列号

        InsuranceItem InsuranceItem = new InsuranceItem();
        AuisAbe auisAbe = new AuisAbe();
        auisAbe.setReissueFlag("0");//改签标记

        InsuranceItem.setAuisAbe(auisAbe);

        insuranceList.setInsurance(insurance);
        insuranceList.setInsuranceItem(InsuranceItem);
        insuranceLists.add(insuranceList);

        insuranceInfo.setInsuranceLists(insuranceLists);

        hlInsurance.setInsuranceInfo(insuranceInfo);

        Auis auis = hanglianUtils.openInsurance(hlInsurance);
        System.out.println("\n"+auis+"\n");*/

        /**
         * 鼎盛
         * */
        HeyDayInsuranceVo heyDayInsuranceVo = new HeyDayInsuranceVo();
        heyDayInsuranceVo.setStartTime("2022-09-01 19:00");
        heyDayInsuranceVo.setArriveTime("2022-09-02 03:00");
        heyDayInsuranceVo.setStartPosition("北京");
        heyDayInsuranceVo.setDestination("上海");
        heyDayInsuranceVo.setTransportNum("MU1234");
        heyDayInsuranceVo.setPhName("李博洋");
        heyDayInsuranceVo.setPhIdType("1");
        heyDayInsuranceVo.setPhIdNo("231182200010260536");
        heyDayInsuranceVo.setPhPhone("18745654672");
        heyDayInsuranceVo.setPhEmail("2196099829@qq.com");

        HeydayUtils heydayUtils = new HeydayUtils();
        HeydayUrlInfo heydayUrlInfo = heydayUtils.heydayInsurance(InsuranceTypeEnum.aviation.getValue());

        String json = JSONArray.toJSON(heyDayInsuranceVo).toString();

        String encode = URLEncoder.encode(json, "utf-8");
        String url = heydayUrlInfo.getUrl() + "&extend=" + encode;
        System.out.println(url);
    }
}
